←Select platform

ConvertPoints(ImageViewerItem,ImageViewerCoordinateType,ImageViewerCoordinateType,LeadPointD[]) Method

Summary

Converts an array of LeadPointD from one coordinates to the other.

Syntax
C#
VB
C++
Public Overridable Sub ConvertPoints( 
   ByVal item As ImageViewerItem, 
   ByVal fromType As ImageViewerCoordinateType, 
   ByVal toType As ImageViewerCoordinateType, 
   ByVal points() As LeadPointD 
) 

Parameters

item

The reference item. This value can be null.

fromType

Original coordinates of points.

toType

Desired target coordinates.

points

Array of points to convert.

Remarks

Use ConvertPoint to convert a single point and ConvertPoints to convert an array of points at once. The viewer needs to create temporary matrices for the conversion, so if you have multiple points, convert them all at once for optimal performance.

Use ConvertRect to convert a rectangle.

The values of item, fromType and toType controls how the point is converted as described below. If the conversion uses an item and the value of item is null, then the viewer will use ActiveItem to support point conversion in a single-view mode.

fromType toType item Description
ImageViewerCoordinateType.Control
ImageViewerCoordinateType.View
Not used Converts a point from control coordinates such as a mouse event in relation to the view
ImageViewerCoordinateType.View
ImageViewerCoordinateType.Control
Not used Converts a point from view coordinates to control. The reverse of the previous operation
ImageViewerCoordinateType.Control
ImageViewerCoordinateType.Item
Used Converts a point from control coordinates such as a mouse event in relation to the whole of the item
ImageViewerCoordinateType.Item
ImageViewerCoordinateType.Control
Used Converts a point from item to control. The reverse of the previous operation
ImageViewerCoordinateType.Control
ImageViewerCoordinateType.Content
Used Converts a point from control coordinates such as a mouse event in relation to the content area of the item
ImageViewerCoordinateType.Content
ImageViewerCoordinateType.Control
Used Converts a point from content to control. The reverse of the previous operation
ImageViewerCoordinateType.Control
ImageViewerCoordinateType.Image
Used Converts a point from control coordinates such as a mouse event in relation to the image of the item
ImageViewerCoordinateType.Image
ImageViewerCoordinateType.Control
Used Converts a point from image to control. The reverse of the previous operation
ImageViewerCoordinateType.Control
ImageViewerCoordinateType.Floater
Used Converts a point from control coordinates such as a mouse event in relation to the floater image of the item
ImageViewerCoordinateType.Floater
ImageViewerCoordinateType.Control
Used Converts a point from image floater to control. The reverse of the previous operation

For more information refer to Image Viewer Layouts, Image Viewer Appearance, Image Viewer Items, Image Viewer Transformation, and Image Viewer Bounds and Transform.

Example
C#
VB
using Leadtools; 
using Leadtools.Controls; 
using Leadtools.Codecs; 
using Leadtools.Drawing; 
using Leadtools.ImageProcessing; 
using Leadtools.ImageProcessing.Color; 
 
 
public void ImageViewerItemTransform_Example(int dy, LeadPoint position) 
{ 
   double total = _imageViewer.GetItemViewBounds(_imageViewer.ActiveItem, ImageViewerItemPart.Item, false).Height; 
   double factor; 
 
   if (total > 0) 
      factor = 1.0 - (dy * 2.0) / total; 
   else 
      factor = 1.0; 
 
   // Get the origin in image coordinate 
   var origin = _imageViewer.ConvertPoint(_imageViewer.ActiveItem, ImageViewerCoordinateType.Control, ImageViewerCoordinateType.Image, position).ToLeadPointD(); 
   // Convert it to whatever the current transform is 
   origin = _imageViewer.ActiveItem.Transform.Transform(origin); 
 
   var transform = LeadMatrix.Identity; 
   transform.ScaleAt(1 / factor, 1 / factor, origin.X, origin.Y); 
   _imageViewer.ActiveItem.Transform = LeadMatrix.Multiply(_imageViewer.ActiveItem.Transform, transform); 
} 
Imports Leadtools 
Imports Leadtools.Controls 
Imports Leadtools.Codecs 
Imports Leadtools.Drawing 
Imports Leadtools.ImageProcessing 
Imports Leadtools.ImageProcessing.Color 
Imports LeadtoolsControlsExamples.LeadtoolsExamples.Common 
 
Public Sub ImageViewerTransform_Example(ByVal dy As Integer, ByVal position As LeadPoint) 
   Dim total As Double = _imageViewer.GetItemViewBounds(_imageViewer.ActiveItem, ImageViewerItemPart.Item, False).Height 
   Dim factor As Double 
 
   If total > 0 Then 
      factor = 1.0 - (dy * 2.0) / total 
   Else 
      factor = 1.0 
   End If 
 
   ' Get the origin in image coordinate 
   Dim origin As LeadPointD = _imageViewer.ConvertPoint(_imageViewer.ActiveItem, ImageViewerCoordinateType.Control, 
                                                        ImageViewerCoordinateType.Image, position).ToLeadPointD() 
   ' Convert it to whatever the current transform is 
   origin = _imageViewer.ActiveItem.Transform.Transform(origin) 
 
   Dim transform As LeadMatrix = LeadMatrix.Identity 
   transform.ScaleAt(1 / factor, 1 / factor, origin.X, origin.Y) 
   _imageViewer.ActiveItem.Transform = LeadMatrix.Multiply(_imageViewer.ActiveItem.Transform, transform) 
End Sub 
Requirements
Target Platforms
Help Version 21.0.2021.7.2
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2021 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.Controls Assembly

Products | Support | Contact Us | Intellectual Property Notices
© 1991-2021 LEAD Technologies, Inc. All Rights Reserved.